server_o = main.o env.o  monitor.o worker.o app.o client.o  config.o comm.o \
	IDL_httpserver_conf.dsc.o IDL_httpserver_conf.dsc.LOG.o \


api_o = tproxy_api.o \

INSTALL_HEADER = tproxy_api.h tproxy_ver.h
INSTALL_APP =  libtproxy_api.so

all	: $(INSTALL_APP) tproxy

libtproxy_api.so : $(api_o)
	gcc -shared -o $@  $(api_o)
	
	
tproxy	:	$(server_o)
	g++ -o $@ $(server_o) -L. -L$(HOME)/lib -ltproxy_api -ltproxy_util -lpthread -ldl -lz -lm -lssl 
#	ctags -R .

.cpp.o	:
	g++ -g -std=c++11 -fPIC -O2 -Wall -Werror -Wno-write-strings -Wno-stringop-truncation  -o $@ -c $< -I. -I/usr/include/mysql -I/usr/include -I$(HOME)/include/tproxy

.c.o	:
	g++ -g -fPIC -O2  -Wall -Werror -Wno-write-strings  -Wno-stringop-truncation -o $@ -c $< -I. -I/usr/include/mysql -I/usr/include -I$(HOME)/include/tproxy
	
#.c.o	:
#	gcc -std=gnu99 -g -fPIC -O2  -Wno-write-strings  -o $@ -c $< -I. -I/usr/include -I$(HOME)/include -D_GNU_SOURCE

clean	:
	rm -f tproxy *.so *.o

install :
	dsc -f IDL_httpserver_conf.dsc -c-json
	make
	mkdir -p  $(HOME)/lib
	mkdir -p  $(HOME)/include/tproxy
	mkdir -p  $(HOME)/bin
	for i in $(INSTALL_APP);\
	do \
		echo "rm -f $$i";\
		rm -f $(HOME)/lib/$$i;\
		echo "cp -f $$i";\
		cp -f $$i $(HOME)/lib;\
	done

	rm -f $(HOME)/bin/tproxy
	cp -f tproxy $(HOME)/bin/

	for i in $(INSTALL_HEADER);\
	do \
		echo "cp -f $$i";\
		cp -f $$i $(HOME)/include/tproxy;\
	done
